<?php
namespace app\index\controller;
use app\index\controller\BaseController;
use app\libs\HxSms;
use think\Cache;
use think\Config;
use think\Db;
use think\Exception;
use think\Request;
use think\session\driver\Redis;

class Test extends BaseController
{
    public function test2(Request $request)
    {
        ini_set('default_socket_timeout', -1);
        $redis=new \Redis();
        $redis->connect("127.0.0.1","6379");
        $result =$redis->subscribe(['test'],[$this,'test1']);
        exit();
    }

    public function test1($instance,$channelName,$message)
    {
        dd($message);
    }

    public function test(){
        $redis=new \Redis();
        $redis->connect("127.0.0.1","6379");
        $message = '测试一下';
        $ret=$redis->publish('test',$message);
        dd($ret);
    }
}